//
//  TemplateFoundDetailsDXXZTableViewCell.m
//  YuTang
//
//  Created by 葛悦彣 on 2024/7/17.
//

#import "TemplateFoundDetailsDXXZTableViewCell.h"

#import "YTBaseSelectStringView.h"
#import "YTBaseEditorStringView.h"
#import "DigitalInputView.h"
#import "TemplateFoundDetailsDHTableViewCell.h"


@interface TemplateFoundDetailsDXXZTableViewCell ()
///必填
@property (nonatomic ,strong) UILabel * forceFlag;
@property (nonatomic ,strong) UILabel * name;
@property (nonatomic ,strong) UILabel * patternlab;

@property (nonatomic ,strong) UIView * makeview;

///选择框
@property (nonatomic ,strong) UIView * XZView;




@end
@implementation TemplateFoundDetailsDXXZTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self)
    {
        [self setupView];
    }
    return self;
}


- (void)setupView{
    
    self.backgroundColor = UIColor.clearColor;
    self.contentView.backgroundColor = UIColor.whiteColor;
    self.userInteractionEnabled = YES;
    self.contentView.userInteractionEnabled = YES;
    
    UIView * makeview = [UIView new];
    self.makeview = makeview;
    makeview.backgroundColor = KcolorHex(@"#F6F7F9");
    [DTKTool YJ:kwt(5) andView:makeview];
    [self.contentView addSubview:makeview];
    [makeview mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.offset(0);
        make.right.offset(kwt(-10));
        make.height.offset(kwt(100));
        make.left.offset(kwt(10));
    }];
    
    UILabel * forceFlag= [DTKTool labelWithText:@"*" andFont:kCFont(18) andTextColor:KcolorHex(@"#FA0F0F")];
    [makeview addSubview:forceFlag];
    self.forceFlag = forceFlag;
    [forceFlag mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.offset(kwt(12));
        make.top.offset(kwt(15));
    }];
    
    
    UILabel * name = [DTKTool labelWithText:@"--" andFont:kCFont(18) andTextColor:KcolorHex(@"#222222")];
    [makeview addSubview:name];
    self.name = name;
    [name mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(forceFlag.mas_right);
        make.top.offset(kwt(15));
    }];
    
    UILabel * patternlab = [DTKTool labelWithText:@" (可多选)" andFont:kCFont(16) andTextColor:KcolorHex(@"#7F7F7F")];
    [makeview addSubview:patternlab];
    self.patternlab = patternlab;
    [patternlab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(name.mas_right);
        make.centerY.equalTo(name);
    }];
    
    UIView * XZView = [UIView new];
    self.XZView = XZView;
    [makeview addSubview:XZView];
    [XZView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.offset(kwt(12));
        make.right.offset(kwt(-12));
        make.top.offset(kwt(45));
        make.bottom.offset(kwt(-5));
    }];
    
}


- (void)setModel:(TemplateFoundDetailsTaskItemModelListModel *)model{
    _model = model;
    ///forceFlag 是否必填
    self.forceFlag.text = (model.forceFlag == 1)? @"*":@"";
    self.name.text = model.name;
    [self.makeview mas_updateConstraints:^(MASConstraintMaker *make) {
        make.height.offset(model.CellH - Kwt(10));
    }];
    [self.XZView.subviews makeObjectsPerformSelector:@selector(removeFromSuperview)];
    CGFloat X = kwt(10);
    CGFloat Y = 0;
    MJWeakSelf
    for (TemplateFoundDetailsItemModelListModel * childModel in model.itemModelList) {//子选项
        
        UIView * btnview = [UIView new];
        btnview.addClickBlock(^{
            [weakSelf btnclick:childModel];
        });
        [DTKTool YJBK:kwt(6) andView:btnview andWidth:1 andColor:childModel.checkedFlag?KcolorHex(@"#0967FF"):KcolorHex(@"#BFBFBF")];
        UILabel * lab = [DTKTool labelWithText:childModel.name andFont:kFont(16) andTextColor:childModel.checkedFlag?KcolorHex(@"#0967FF"):KcolorHex(@"#373C45")];
        [btnview addSubview:lab];
        lab.textAlignment = NSTextAlignmentCenter;
        [lab mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.offset(kwt(10));
            make.right.offset(kwt(-10));
            make.centerY.offset(0);
        }];
        if(childModel.checkedFlag){
            UIImageView * xzimg = kimageView(@"template_selete");
            [btnview addSubview:xzimg];
            [xzimg mas_makeConstraints:^(MASConstraintMaker *make) {
                make.right.bottom.offset(0);
                make.height.offset(kwt(11));
                make.width.offset(kwt(10));
            }];
        }
        
        [self.XZView addSubview:btnview];
        if(X + childModel.nameW > kwt(340)){
            X = kwt(10);
            Y += kwt(48);
        }
        btnview.frame = CGRectMake(X, Y, childModel.nameW, kwt(32));
        X += childModel.nameW + kwt(14);
    }
    
}

- (void)btnclick:(TemplateFoundDetailsItemModelListModel *)model{
    //    if(self.model.pattern == 1){//是单选
    //        for (TemplateFoundDetailsItemModelListModel * childModel in self.model.itemModelList) {//子选项
    //            if(childModel == model){
    //                model.checkedFlag = (model.checkedFlag == 1)?0:1;
    //            } else {
    //                childModel.checkedFlag = 0;
    //            }
    //        }
    //    } else {
    model.checkedFlag = (model.checkedFlag == 1)?0:1;
    //    }
    
    if(self.openReloadBlock){
        self.openReloadBlock();
    }
}

@end

@interface TemplateFoundDetailsRWDXXZTableViewCell()

@property (nonatomic ,strong) UIView * AllZview;
@end
@implementation TemplateFoundDetailsRWDXXZTableViewCell

- (void)setupView{
    [super setupView];
    
    UIView * AllZview = [UIView new];
    self.AllZview = AllZview;
    AllZview.backgroundColor = UIColor.whiteColor;
    [DTKTool YJ:kwt(5) andView:AllZview];
    [self.contentView addSubview:AllZview];
    [AllZview mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.makeview.mas_bottom).offset(kwt(10));
        make.right.offset(kwt(-10));
        make.left.offset(kwt(10));
        make.bottom.offset(kwt(-10));
    }];
    
    
}
- (void)setModel:(TemplateFoundDetailsTaskItemModelListModel *)model{
    [super setModel:model];
    MJWeakSelf
        [self.AllZview.subviews makeObjectsPerformSelector:@selector(removeFromSuperview)];
        BOOL isHave = NO;
        ///判断是否有子选项显示
        for (TemplateFoundDetailsItemModelListModel * itemList in model.itemModelList) {
            if(itemList.checkedFlag == 1){
                if(itemList.itemList.count > 0){
                    isHave = YES;
                }
            }
        }
        [self.AllZview mas_updateConstraints:^(MASConstraintMaker *make) {
            make.bottom.offset(isHave ? kwt(-10):0);
        }];
        
        
        CGFloat Y = 0;
        for (TemplateFoundDetailsItemModelListModel * itemList in model.itemModelList) {
            if(itemList.checkedFlag == 1){
                if(itemList.itemList.count > 1){///多个任务包一起
                    UIView * listview = [UIView new];
                    listview.backgroundColor = KcolorHex(@"#F6F7F9");
                    [self.AllZview addSubview:listview];
                    [DTKTool YJ:kwt(5) andView:listview];
                    [listview mas_makeConstraints:^(MASConstraintMaker *make) {
                        make.left.right.offset(0);
                        make.top.offset(Y) ;
                        make.height.offset(itemList.itemListViewH - kwt(10));
                    }];
                    UILabel * lab = [DTKTool labelWithText:itemList.name andFont:kFont(17) andTextColor:KcolorHex(@"#222222")];
                    [listview addSubview:lab];
                    lab.textAlignment = NSTextAlignmentCenter;
                    [lab mas_makeConstraints:^(MASConstraintMaker *make) {
                        make.left.offset(kwt(12));
                        make.top.offset(kwt(16));
                    }];
                   CGFloat tempY = kwt(45);
                    for (TemplateFoundDetailsItemListModel * item in itemList.itemList) {
                        /// 样式;1:多项选择 2:下单单选3:数字输入框4:单行文本 5:多行文本
                        if(item.pattern == 1){
                            CGFloat X = kwt(10);
                            CGFloat dxY = kwt(45);
                            UIView * dxview = [UIView new];
                            dxview.backgroundColor = KcolorHex(@"#F6F7F9");
                            [DTKTool YJ:kwt(5) andView:dxview];
                            [listview addSubview:dxview];
                            [dxview mas_makeConstraints:^(MASConstraintMaker *make) {
                                make.top.offset(tempY);
                                make.left.right.offset(0);
                                make.height.offset(item.viewH - kwt(10));
                            }];
                            
                            
                            UILabel * lab = [DTKTool labelWithText:@"" andFont:kCFont(17) andTextColor:KcolorHex(@"#222222")];
                            lab.attributedText = [DTKTool AttributedStringWithStr:[NSString stringWithFormat: @"%@%@",((item.forceFlag == 1)?@"*":@""),item.name] andNodeColor:KcolorHex(@"#222222") andSeledColor:KcolorHex(@"#FA0F0F") andFont:kCFont(17) andPattenr:@"[*]"];
                            [dxview addSubview:lab];
                            [lab mas_makeConstraints:^(MASConstraintMaker *make) {
                                make.left.offset(kwt(10));
                                make.top.offset(kwt(14));
                                make.height.offset(kwt(18));
                            }];
                            UILabel * templab = [DTKTool labelWithText:@" (可多选)" andFont:kFont(17) andTextColor:KcolorHex(@"#7F7F7F")];
                            [dxview addSubview:templab];
                            templab.textAlignment = NSTextAlignmentCenter;
                            [templab mas_makeConstraints:^(MASConstraintMaker *make) {
                                make.left.equalTo(lab.mas_right);
                                make.centerY.equalTo(lab);
                            }];
                        
                            
                            for (TemplateFoundDetailsChildrenModelListModel * childModel in item.childrenModelList) {
                                
                                UIView * btnview = [UIView new];
                                btnview.addClickBlock(^{
                                    [weakSelf btnclick:childModel];
                                });
                                [DTKTool YJBK:kwt(6) andView:btnview andWidth:1 andColor:childModel.checkedFlag?KcolorHex(@"#0967FF"):KcolorHex(@"#BFBFBF")];
                                UILabel * lab = [DTKTool labelWithText:childModel.name andFont:kFont(16) andTextColor:childModel.checkedFlag?KcolorHex(@"#0967FF"):KcolorHex(@"#373C45")];
                                [btnview addSubview:lab];
                                lab.textAlignment = NSTextAlignmentCenter;
                                [lab mas_makeConstraints:^(MASConstraintMaker *make) {
                                    make.left.offset(kwt(10));
                                    make.right.offset(kwt(-10));
                                    make.centerY.offset(0);
                                }];
                                if(childModel.checkedFlag){
                                    UIImageView * xzimg = kimageView(@"template_selete");
                                    [btnview addSubview:xzimg];
                                    [xzimg mas_makeConstraints:^(MASConstraintMaker *make) {
                                        make.right.bottom.offset(0);
                                        make.height.offset(kwt(11));
                                        make.width.offset(kwt(10));
                                    }];
                                }
                                
                                [dxview addSubview:btnview];
                                if(X + childModel.nameW > kwt(340)){
                                    X = kwt(10);
                                    dxY += kwt(48);
                                }
                                btnview.frame = CGRectMake(X, dxY, childModel.nameW, kwt(32));
                                X += childModel.nameW + kwt(10);
                            }
                            tempY += item.viewH - kwt(10);
                        } else  if(item.pattern == 2){
                            YTBaseSelectStringView * view = [YTBaseSelectStringView NewViewWithNil];
                            view.forceFlag = item.forceFlag;
                            view.name = item.name;
                            view.content = item.seledModel.name;
                            view.block = ^(NSString * _Nonnull content) {
                                NSMutableArray * nameArray = [NSMutableArray array];
                                int i = 0;
                                int selectIndex = 0;
                                for (TemplateFoundDetailsChildrenModelListModel * itemmodel in item.childrenModelList) {
                                    [nameArray addObject:itemmodel.name];
                                    if([item.seledModel.name isEqualToString: itemmodel.name]){
                                        selectIndex = i;
                                    }
                                    i ++;
                                }
                                [BRStringPickerView showPickerWithTitle:[NSString stringWithFormat:@"请选择%@",item.name] dataSourceArr:nameArray selectIndex:selectIndex resultBlock:^(BRResultModel * _Nullable resultModel) {
                                    for (TemplateFoundDetailsChildrenModelListModel * itemmodel in item.childrenModelList) {
                                        if([itemmodel.name isEqualToString:resultModel.value]){
                                            itemmodel.checkedFlag = 1;
                                        } else {
                                            itemmodel.checkedFlag = 0;
                                        }
                                    }
                                    if(weakSelf.openReloadBlock){
                                        weakSelf.openReloadBlock();
                                    }
                                }];
                            };
                            [listview addSubview: view];
                            [view mas_makeConstraints:^(MASConstraintMaker *make) {
                                make.left.right.offset(0);
                                make.top.offset(tempY);
                                make.height.offset(item.viewH - kwt(10));
                            }];
                            tempY += item.viewH - kwt(10);
                        } else  if(item.pattern == 3){
                            
                            UIView * makeview = [UIView new];
                            makeview.backgroundColor = KcolorHex(@"#F6F7F9");
                            [DTKTool YJ:kwt(5) andView:makeview];
                            [listview addSubview:makeview];
                            [makeview mas_makeConstraints:^(MASConstraintMaker *make) {
                                make.top.offset(tempY);
                                make.left.right.offset(0);
                                make.height.offset(item.viewH - kwt(10));
                            }];
                            
                            UILabel * name = [DTKTool labelWithText:@"" andFont:kCFont(18) andTextColor:KcolorHex(@"#222222")];
                            [makeview addSubview:name];
                            name.attributedText = [DTKTool AttributedStringWithStr:[NSString stringWithFormat:@"%@%@",(item.forceFlag==1)?@"*":@"",item.name] andNodeColor:KcolorHex(@"#222222") andSeledColor:KcolorHex(@"#FA0F0F") andFont:kCFont(18) andPattenr:@"[*]"];
                            self.name = name;
                            [name mas_makeConstraints:^(MASConstraintMaker *make) {
                                make.left.offset(kwt(12));
                                make.centerY.offset(0);
                                make.width.offset(kwt(145));
                            }];
                            
                            DigitalInputView * inputview = [DigitalInputView DKNewView];
                            inputview.model = item;///有数据不管类型
                            [makeview addSubview:inputview];
                            inputview.openReloadBlock = ^{
                                if(weakSelf.openReloadBlock){
                                    weakSelf.openReloadBlock();
                                }
                            };
                            inputview.openHUDBlock = ^(NSString * _Nonnull str) {
                                if(weakSelf.openHUDBlock){
                                    weakSelf.openHUDBlock(str);
                                }
                            };
                            [inputview mas_makeConstraints:^(MASConstraintMaker *make) {
                                make.right.offset(kwt(-12));
                                make.centerY.offset(0);
                                make.width.offset(kwt(170));
                                make.height.offset(kwt(32));
                            }];
                            
                            
                            tempY += item.viewH - kwt(10);
                            
                        } else  if(item.pattern == 4){
                            
                            YTBaseEditorStringView * view = [YTBaseEditorStringView NewViewWithNil];
                            view.forceFlag = item.forceFlag;
                            view.name = item.name;
                            view.content = item.content;
                            view.block = ^(NSString * _Nonnull content) {
                                item.content = content;
                            };
                            
                            [listview addSubview: view];
                            [view mas_makeConstraints:^(MASConstraintMaker *make) {
                                make.left.right.offset(0);
                                make.top.offset(tempY);
                                make.height.offset(item.viewH - kwt(10));
                            }];
                            tempY+= item.viewH - kwt(10);
                        } else  if(item.pattern == 5){
                            TemplateFoundDetailsDHView * view = [TemplateFoundDetailsDHView NewView];
                            view.model = item;
                            [listview addSubview: view];
                            [view mas_makeConstraints:^(MASConstraintMaker *make) {
                                make.left.right.offset(0);
                                make.top.offset(tempY);
                                make.height.offset(item.viewH - kwt(10));
                            }];
                            tempY += item.viewH - kwt(10);
                        }
                    }
                    Y += itemList.itemListViewH;
                } else {///单个任务项
                    for (TemplateFoundDetailsItemListModel * item in itemList.itemList) {
                        /// 样式;1:多项选择 2:下单单选3:数字输入框4:单行文本 5:多行文本
                        if(item.pattern == 1){
                            CGFloat X = kwt(10);
                            CGFloat dxY = kwt(45);
                            UIView * dxview = [UIView new];
                            dxview.backgroundColor = KcolorHex(@"#F6F7F9");
                            [DTKTool YJ:kwt(5) andView:dxview];
                            [self.AllZview addSubview:dxview];
                            [dxview mas_makeConstraints:^(MASConstraintMaker *make) {
                                make.top.offset(Y);
                                make.left.right.offset(0);
                                make.height.offset(item.viewH - kwt(10));
                            }];
                            
                            
                            UILabel * lab = [DTKTool labelWithText:@"" andFont:kCFont(17) andTextColor:KcolorHex(@"#222222")];
                            lab.attributedText = [DTKTool AttributedStringWithStr:[NSString stringWithFormat: @"%@%@",((item.forceFlag == 1)?@"*":@""),item.name] andNodeColor:KcolorHex(@"#222222") andSeledColor:KcolorHex(@"#FA0F0F") andFont:kCFont(17) andPattenr:@"[*]"];
                            [dxview addSubview:lab];
                            [lab mas_makeConstraints:^(MASConstraintMaker *make) {
                                make.left.offset(kwt(10));
                                make.top.offset(kwt(14));
                                make.height.offset(kwt(18));
                            }];
                            UILabel * templab = [DTKTool labelWithText:@" (可多选)" andFont:kFont(17) andTextColor:KcolorHex(@"#7F7F7F")];
                            [dxview addSubview:templab];
                            templab.textAlignment = NSTextAlignmentCenter;
                            [templab mas_makeConstraints:^(MASConstraintMaker *make) {
                                make.left.equalTo(lab.mas_right);
                                make.centerY.equalTo(lab);
                            }];
                         
                            for (TemplateFoundDetailsChildrenModelListModel * childModel in item.childrenModelList) {
                                
                                UIView * btnview = [UIView new];
                                btnview.addClickBlock(^{
                                    [weakSelf btnclick:childModel];
                                });
                                [DTKTool YJBK:kwt(6) andView:btnview andWidth:1 andColor:childModel.checkedFlag?KcolorHex(@"#0967FF"):KcolorHex(@"#BFBFBF")];
                                UILabel * lab = [DTKTool labelWithText:childModel.name andFont:kFont(16) andTextColor:childModel.checkedFlag?KcolorHex(@"#0967FF"):KcolorHex(@"#373C45")];
                                [btnview addSubview:lab];
                                lab.textAlignment = NSTextAlignmentCenter;
                                [lab mas_makeConstraints:^(MASConstraintMaker *make) {
                                    make.left.offset(kwt(10));
                                    make.right.offset(kwt(-10));
                                    make.centerY.offset(0);
                                }];
                                if(childModel.checkedFlag){
                                    UIImageView * xzimg = kimageView(@"template_selete");
                                    [btnview addSubview:xzimg];
                                    [xzimg mas_makeConstraints:^(MASConstraintMaker *make) {
                                        make.right.bottom.offset(0);
                                        make.height.offset(kwt(11));
                                        make.width.offset(kwt(10));
                                    }];
                                }
                                
                                [dxview addSubview:btnview];
                                if(X + childModel.nameW > kwt(340)){
                                    X = kwt(10);
                                    dxY += kwt(48);
                                }
                                btnview.frame = CGRectMake(X, dxY, childModel.nameW, kwt(32));
                                X += childModel.nameW + kwt(10);
                            }
                            Y+= item.viewH;
                        } else  if(item.pattern == 2){
                            YTBaseSelectStringView * view = [YTBaseSelectStringView NewViewWithUP];
                            view.forceFlag = item.forceFlag;
                            view.name = item.name;
                            view.content = item.seledModel.name;
                            view.block = ^(NSString * _Nonnull content) {
                                NSMutableArray * nameArray = [NSMutableArray array];
                                int i = 0;
                                int selectIndex = 0;
                                for (TemplateFoundDetailsChildrenModelListModel * itemmodel in item.childrenModelList) {
                                    [nameArray addObject:itemmodel.name];
                                    if([item.seledModel.name isEqualToString: itemmodel.name]){
                                        selectIndex = i;
                                    }
                                    i ++;
                                }
                                [BRStringPickerView showPickerWithTitle:[NSString stringWithFormat:@"请选择%@",item.name] dataSourceArr:nameArray selectIndex:selectIndex resultBlock:^(BRResultModel * _Nullable resultModel) {
                                    for (TemplateFoundDetailsChildrenModelListModel * itemmodel in item.childrenModelList) {
                                        if([itemmodel.name isEqualToString:resultModel.value]){
                                            itemmodel.checkedFlag = 1;
                                        } else {
                                            itemmodel.checkedFlag = 0;
                                        }
                                    }
                                    if(weakSelf.openReloadBlock){
                                        weakSelf.openReloadBlock();
                                    }
                                }];
                            };
                            [self.AllZview addSubview: view];
                            [view mas_makeConstraints:^(MASConstraintMaker *make) {
                                make.left.right.offset(0);
                                make.top.offset(Y);
                                make.height.offset(item.viewH);
                            }];
                            Y+= item.viewH;
                        } else  if(item.pattern == 3){
                            
                            UIView * makeview = [UIView new];
                            makeview.backgroundColor = KcolorHex(@"#F6F7F9");
                            [DTKTool YJ:kwt(5) andView:makeview];
                            [self.AllZview addSubview:makeview];
                            [makeview mas_makeConstraints:^(MASConstraintMaker *make) {
                                make.top.offset(Y);
                                make.left.right.offset(0);
                                make.height.offset(item.viewH - kwt(10));
                            }];
                            
                            UILabel * name = [DTKTool labelWithText:@"" andFont:kCFont(18) andTextColor:KcolorHex(@"#222222")];
                            [makeview addSubview:name];
                            name.attributedText = [DTKTool AttributedStringWithStr:[NSString stringWithFormat:@"%@%@",(item.forceFlag==1)?@"*":@"",item.name] andNodeColor:KcolorHex(@"#222222") andSeledColor:KcolorHex(@"#FA0F0F") andFont:kCFont(18) andPattenr:@"[*]"];
                            self.name = name;
                            [name mas_makeConstraints:^(MASConstraintMaker *make) {
                                make.left.offset(kwt(12));
                                make.centerY.offset(0);
                                make.width.offset(kwt(145));
                            }];
                            
                            DigitalInputView * inputview = [DigitalInputView DKNewView];
                            inputview.model = item;///有数据不管类型
                            [makeview addSubview:inputview];
                            inputview.openReloadBlock = ^{
                                if(weakSelf.openReloadBlock){
                                    weakSelf.openReloadBlock();
                                }
                            };
                            inputview.openHUDBlock = ^(NSString * _Nonnull str) {
                                if(weakSelf.openHUDBlock){
                                    weakSelf.openHUDBlock(str);
                                }
                            };
                            [inputview mas_makeConstraints:^(MASConstraintMaker *make) {
                                make.right.offset(kwt(-12));
                                make.centerY.offset(0);
                                make.width.offset(kwt(170));
                                make.height.offset(kwt(32));
                            }];
                            
                            
                            Y+= item.viewH;
                            
                        } else  if(item.pattern == 4){
                            
                            YTBaseEditorStringView * view = [YTBaseEditorStringView NewViewWithUP];
                            view.forceFlag = item.forceFlag;
                            view.name = item.name;
                            view.content = item.content;
                            view.block = ^(NSString * _Nonnull content) {
                                item.content = content;
                            };
                            
                            [self.AllZview addSubview: view];
                            [view mas_makeConstraints:^(MASConstraintMaker *make) {
                                make.left.right.offset(0);
                                make.top.offset(Y);
                                make.height.offset(item.viewH);
                            }];
                            Y+= item.viewH;
                        } else  if(item.pattern == 5){
                            TemplateFoundDetailsDHView * view = [TemplateFoundDetailsDHView NewView];
                            view.model = item;
                            [self.AllZview addSubview: view];
                            [view mas_makeConstraints:^(MASConstraintMaker *make) {
                                make.left.right.offset(0);
                                make.top.offset(Y);
                                make.height.offset(item.viewH);
                            }];
                            Y+= item.viewH;
                        }
                    }
                }
            }
        }
}


- (void)btnclick:(TemplateFoundDetailsChildrenModelListModel *)model{
    //    if(self.model.pattern == 1){//是单选
    //        for (TemplateFoundDetailsItemModelListModel * childModel in self.model.itemModelList) {//子选项
    //            if(childModel == model){
    //                model.checkedFlag = (model.checkedFlag == 1)?0:1;
    //            } else {
    //                childModel.checkedFlag = 0;
    //            }
    //        }
    //    } else {
    model.checkedFlag = (model.checkedFlag == 1)?0:1;
    //    }
    
    if(self.openReloadBlock){
        self.openReloadBlock();
    }
}
@end
